package souralven.jcomicreader.controller.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

public class ExitListener extends WindowAdapter implements ActionListener {

	private JFrame parent;
	
	public ExitListener(final JFrame parent) {
		this.parent = parent;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		exit();
	}

	@Override
	public void windowClosing(WindowEvent e) {
		exit();
	}

	private void exit() {
		parent.dispose();
		System.exit(0);
	}
}